<?php
header('Content-type:text/json');
header('Content-type:text/html;charset=utf-8'); 
function regex($value, $rule){	
	return is_scalar($value) && 1 === preg_match($rule, (string) $value);
}

//姓名
if( isset($_POST['realname']) ){
	$realname = $_POST['realname'];
}else{
	$realname = '';
}
$chsAlpha = '/^[\x{4e00}-\x{9fa5}a-zA-Z]+$/u';
if( !regex($realname, $chsAlpha) ){
	echo json_encode(['status'=>'error','message'=>'请输入正确的姓名']);
	exit;
}
//手机
if( isset($_POST['mobile']) ){
	$mobile = $_POST['mobile'];
}else{
	$mobile = '';
}
$rule = '/^1[3-8]\d{9}$/';
if( !regex($mobile, $rule) ){
	echo json_encode(['status'=>'error','message'=>'请输入正确的手机号码']);
	exit;
}

//意向
if( isset($_POST['yixiang']) ){
	$yixiang = $_POST['yixiang'];
}else{
	$yixiang = '';
}
//类型
if( isset($_POST['typeid']) ){
	$typeid = $_POST['typeid'];
}else{
	$typeid = 1;
}
/*
$realname = '博量';
$mobile = '13526590201';
$gender = 1;
*/
//提交数据
$url = 'http://yunkehui.yeen.com/platform/message/add';
$url = 'http://admin.yunkehui.com/platform/message/add.html';
$data = [
	'realname'		=> $realname,
	//'gender'		=> $gender,
	'mobile'		=> $mobile,
	'yixiang'		=> $yixiang,
	'typeid'		=> $typeid,
];
$curl = curl_init();		//初始化
curl_setopt($curl, CURLOPT_URL, $url );	//设置抓取的url
curl_setopt($curl, CURLOPT_HEADER, false);	//设置头文件的信息作为数据流输出
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);	//设置获取的信息以文件流的形式返回，而不是直接输出
curl_setopt($curl, CURLOPT_POST, 1);	//设置post方式提交
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$res = curl_exec($curl);		//执行命令
curl_close($curl);	//关闭URL请求

echo $res;
exit;




